#include <stdio.h>
//#include <iostream>
#include <string.h>
//#include <string>
using namespace std;

const int MAX_TEXT_SIZE = 10000;
char Text[MAX_TEXT_SIZE+2];
int TextLen = 0;

bool CheckComment(char*& pos) {
    pos += 2;
    for (; *pos; ++pos)
        if (*pos == '*' && *(pos+1) == ')') {
            ++pos;
            return true;
        }
    return false;
}

bool IsValidArithmeticSymbol(char ch) {
    return strchr("=+-*/0123456789)(", ch);
}

bool CheckArithmetic(char*& pos) {
    ++pos;
    int bracketsCnt = 1;
    for (;*pos; ++pos) {
        if (*pos == '(' && *(pos+1) == '*')
            if (!CheckComment(pos))
                return false;

        if (!IsValidArithmeticSymbol(*pos))
            return false;
        else if (*pos == '(')
            ++bracketsCnt;
        else if (*pos == ')')
            --bracketsCnt;
        if (bracketsCnt == 0)
            break;
    }
    return (bracketsCnt == 0);
    //return true;
}

int main() {
    char c;
    char *pos = Text;
    while ((c = getchar()) != EOF)
        *pos++ = c;
    *pos = 0;

    printf("\n%s\n", Text);

    bool ok = true;
    pos = Text;
    for (; *pos; ++pos) {
        if (*pos == '(') {
            const char nch = *(pos+1);
            if (nch == 0)
                ok = false;
            else if (nch == '*')
                ok = CheckComment(pos);
            else
                ok = CheckArithmetic(pos);

            if (!ok)
                break;
        }
    }

    //cout << (ok ? "YES" : "NO") << endl;
    printf(ok ? "YES\n" : "NO\n");
    return 0;
}
